package com.qf.service.impl;

import com.qf.dao.UserDao;
import com.qf.dao.UserDaoImpl;
import com.qf.pojo.User;
import com.qf.service.AdminService;
import com.qf.util.MD5Utils;

/**
 * @author 千锋健哥
 */
public class AdminServiceImpl implements AdminService {

    @Override
    public boolean login(String userName, String passWord) {
        //1. 根据用户名查询
        UserDao userDao = new UserDaoImpl();
        User user = userDao.findUserByUserName(userName);

        //2. 判断是否能查到结果, 如果查不到, 登录失败
        if (user == null) {
            return false;
        } else {
            //3. 如果能够查询到用户, 判断密码是否正确
            //对密码明文进行加密
            String securit = MD5Utils.md5(passWord);
            if (user.getPassword().equals(securit)) {
                return true;
            }
        }

        return false;
    }

}
